***Replication do file for "Stolwijk and Vis (2020). Politicians, the Representativeness Heuristic and Decision-Making Biases. Political Behavior"

**load the replication data:
use "...\Stolwijk_Vis_polrepresentativeness.dta",clear



*****descriptives:
***politicians:
univar woman educ birthyear polexperience  mathskill Q44 righttoleft if politician==1 // Q44=statcourses
tab party if politician==1
***students:
univar woman educ age polinterest  mathskill Q44 righttoleft if politician==0 // Q44=statcourses


*******hypothesis testing politicians***************
***conjunction (linda scenario) politicians
tab1 conjunction fembankorder if politician==1

**headlines
ttest logheadlines_comb if politician==1, by(terrorcon)

**earthquake
ttest logearthquake_comb if politician==1, by(aardbevingcon)


**nuisance importance
ttest issueimportance if politician==1, by(conditie50)


**nuisance total budget
ttest logtotbudget if politician==1, by(conditie50)

***online appendix 9: ADDITIONAL ANALYSIS NUISANCE SCENARIO
**within subject test of difference in budget allocated to 23 vs 53 people causing nuisance:
ttest logtot53bud==logbudget23ipv53 if politician==1 // whether politicians originally asked about 53 people causing a nuisance would indicate a different budget if there had been only 23 people
ttest logtot23bud==logbudget53ipv23 if politician==1 // whether politicians originally asked about 23 people causing a nuisance would indicate a different budget if there had been 53 people instead

*******politician graphs*************************

**conjunction
keep if  politician==1
graph bar (count) ,over(conjunction, gap(*0.3)) graphregion(color(white)) bar(1, color(ebblue*0.9)) 

**headlines
keep if politician==1
collapse (mean) meanlogheadlines_comb= logheadlines_comb (sd) sdlogheadlines_comb=logheadlines_comb (count) n=logheadlines_comb, by(terrorcon)
generate hilogheadlines_comb = meanlogheadlines_comb + invttail(n-1,0.025)*(sdlogheadlines_comb / sqrt(n))
generate lologheadlines_comb = meanlogheadlines_comb - invttail(n-1,0.025)*(sdlogheadlines_comb / sqrt(n))
graph twoway (bar meanlogheadlines_comb terrorcon, barw(0.9) fcolor(ebblue)) (rcap hilogheadlines_comb lologheadlines_comb terrorcon), ///
xlabel( 0 "general" 1 "terrorist attack" , noticks) ///
       xtitle("condition") ytitle("estimated likelihood (log%)")  legend(off) graphregion(color(white)) ylab(0(0.5)3)
 

use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	  

**earthquake
keep if politician==1
collapse (mean) meanlogearthquake_comb= logearthquake_comb (sd) sdlogearthquake_comb=logearthquake_comb (count) n=logearthquake_comb, by(aardbevingcon)
generate hilogearthquake_comb = meanlogearthquake_comb + invttail(n-1,0.025)*(sdlogearthquake_comb / sqrt(n))
generate lologearthquake_comb = meanlogearthquake_comb - invttail(n-1,0.025)*(sdlogearthquake_comb / sqrt(n))
graph twoway (bar meanlogearthquake_comb aardbevingcon, barw(0.9) fcolor(ebblue)) (rcap hilogearthquake_comb lologearthquake_comb aardbevingcon), ///
xlabel( 0 "natural disaster" 1 "earthquake" , noticks) ///
       xtitle("condition") ytitle("estimated likelihood (log%)")  legend(off) graphregion(color(white)) ylab(0(0.25)2)


use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	  

**nuisance importance
keep if politician==1
collapse (mean) meanissueimportance= issueimportance (sd) sdissueimportance=issueimportance (count) n=issueimportance, by(conditie50)
generate hiissueimportance = meanissueimportance + invttail(n-1,0.025)*(sdissueimportance / sqrt(n))
generate loissueimportance = meanissueimportance - invttail(n-1,0.025)*(sdissueimportance / sqrt(n))
graph twoway (bar meanissueimportance conditie50, barw(0.9) fcolor(ebblue) bargap(0)) (rcap hiissueimportance loissueimportance conditie50), ///
xlabel( 0 "23 people who cause a nuisance" 1 "53 people who cause a nuisance" , noticks) ///
       xtitle("condition") ytitle("importance rating (1-6)")  legend(off) graphregion(color(white)) ylab(1(1)6)


use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	  

**nuisance total budget
keep if politician==1
collapse (mean) meanlogtotbudget=logtotbudget meancounterbud=counterbud (sd) sdlogtotbudget=logtotbudget sdcounterbud=counterbud (count) n=logtotbudget nc=counterbud, by(conditie50)
generate hilogtotbudget = meanlogtotbudget + invttail(n-1,0.025)*(sdlogtotbudget / sqrt(n))
generate lologtotbudget = meanlogtotbudget - invttail(n-1,0.025)*(sdlogtotbudget / sqrt(n))
generate hicounterbud = meancounterbud + invttail(n-1,0.025)*(sdcounterbud / sqrt(n))
generate locounterbud = meancounterbud - invttail(n-1,0.025)*(sdcounterbud / sqrt(n))

graph twoway (bar meanlogtotbudget conditie50, barw(0.9) fcolor(ebblue) bargap(0)) (rcap hilogtotbudget lologtotbudget conditie50) ///
	, xlabel( 0 "23 people who cause a nuisance" 1 "53 people who cause a nuisance" , noticks) ///
       xtitle("condition") ytitle("budget allocated (log of k euros)")  legend(off) graphregion(color(white)) ylab(0(1)6)


use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	  


************student hypothesis testing****************
***conjunction
tab1 conjunction fembankorder if politician==0
tab conjunction if politician==0


**headlines
ttest logheadlines_comb if politician==0, by(terrorcon)

**earthquake
ttest logearthquake_comb if politician==0, by(aardbevingcon)


**nuisance importance
ttest issueimportance if politician==0, by(conditie50)

**nuisance total budget
ttest logtotbudget if politician==0, by(conditie50)



*********student graphs******************************
***conjunction
keep if  politician==0
graph bar (count) ,over(conjunction, gap(*0.3)) graphregion(color(white)) bar(1, color(ebblue*0.9)) 
***headlines
collapse (mean) meanlogheadlines_comb= logheadlines_comb (sd) sdlogheadlines_comb=logheadlines_comb (count) n=logheadlines_comb, by(terrorcon)
generate hilogheadlines_comb = meanlogheadlines_comb + invttail(n-1,0.025)*(sdlogheadlines_comb / sqrt(n))
generate lologheadlines_comb = meanlogheadlines_comb - invttail(n-1,0.025)*(sdlogheadlines_comb / sqrt(n))
graph twoway (bar meanlogheadlines_comb terrorcon, barw(0.9) fcolor(ebblue)) (rcap hilogheadlines_comb lologheadlines_comb terrorcon), ///
xlabel( 0 "general" 1 "terrorist attack" , noticks) ///
       xtitle("condition") ytitle("estimated likelihood (log%)")  legend(off) graphregion(color(white)) ylab(0(0.5)3)

use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	  

**earthquake
keep if politician==0
collapse (mean) meanlogearthquake_comb= logearthquake_comb (sd) sdlogearthquake_comb=logearthquake_comb (count) n=logearthquake_comb, by(aardbevingcon)
generate hilogearthquake_comb = meanlogearthquake_comb + invttail(n-1,0.025)*(sdlogearthquake_comb / sqrt(n))
generate lologearthquake_comb = meanlogearthquake_comb - invttail(n-1,0.025)*(sdlogearthquake_comb / sqrt(n))
graph twoway (bar meanlogearthquake_comb aardbevingcon, barw(0.9) fcolor(ebblue)) (rcap hilogearthquake_comb lologearthquake_comb aardbevingcon), ///
xlabel( 0 "natural disaster" 1 "earthquake" , noticks) ///
       xtitle("condition") ytitle("estimated likelihood (log%)")  legend(off) graphregion(color(white)) ylab(0(0.25)2)

use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	  

**nuisance importance
keep if politician==0
collapse (mean) meanissueimportance= issueimportance (sd) sdissueimportance=issueimportance (count) n=issueimportance, by(conditie50)
generate hiissueimportance = meanissueimportance + invttail(n-1,0.025)*(sdissueimportance / sqrt(n))
generate loissueimportance = meanissueimportance - invttail(n-1,0.025)*(sdissueimportance / sqrt(n))
graph twoway (bar meanissueimportance conditie50, barw(0.9) fcolor(ebblue) bargap(0)) (rcap hiissueimportance loissueimportance conditie50), ///
xlabel( 0 "23 people who cause a nuisance" 1 "53 people who cause a nuisance" , noticks) ///
       xtitle("condition") ytitle("importance rating (1-6)")  legend(off) graphregion(color(white)) ylab(1(1)6)


use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	  

**nuisance total budget

keep if politician==0
collapse (mean) meanlogtotbudget=logtotbudget meancounterbud=counterbud (sd) sdlogtotbudget=logtotbudget sdcounterbud=counterbud (count) n=logtotbudget nc=counterbud, by(conditie50)
generate hilogtotbudget = meanlogtotbudget + invttail(n-1,0.025)*(sdlogtotbudget / sqrt(n))
generate lologtotbudget = meanlogtotbudget - invttail(n-1,0.025)*(sdlogtotbudget / sqrt(n))
generate hicounterbud = meancounterbud + invttail(n-1,0.025)*(sdcounterbud / sqrt(n))
generate locounterbud = meancounterbud - invttail(n-1,0.025)*(sdcounterbud / sqrt(n))

graph twoway (bar meanlogtotbudget conditie50, barw(0.9) fcolor(ebblue) bargap(0)) (rcap hilogtotbudget lologtotbudget conditie50) ///
	, xlabel( 0 "23 people who cause a nuisance" 1 "53 people who cause a nuisance" , noticks) ///
       xtitle("condition") ytitle("budget allocated (log of k euros)")  legend(off) graphregion(color(white)) ylab(0(1)6)
  
use "...\Stolwijk_Vis_polrepresentativeness.dta",clear	
  
*****Table S8. Logistic regressions predicting expectation orders for left wing and right wing politicians in the Linda/Vera scenario. 
logit conjunction leftwing if politician==1
outreg using explorH2.doc, replace se starlevels(5,1,0.1) starloc(1)   sdec(2)
logit conjunction rightwing if politician==1
outreg using explorH2.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
logit revstereocon leftwing if politician==1
outreg using explorH2.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
logit revstereocon rightwing if politician==1
outreg using explorH2.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
logit stereocon leftwing if politician==1
outreg using explorH2.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
logit stereocon rightwing if politician==1
outreg using explorH2.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)


***Table S10. Adding control variables to the regression/logit results for each test.
logit conjunction woman educ polexperience  mathskill righttoleft  if politician==1
outreg using control1log.doc, replace se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logheadlines_comb terrorcon  woman educ polexperience  mathskill righttoleft if politician==1 
outreg using control1log.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logearthquake_comb aardbevingcon  woman educ polexperience  mathskill righttoleft if politician==1
outreg using control1log.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg issueimportance i.conditie50 woman educ polexperience  mathskill righttoleft if politician==1
outreg using control1log.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
regress logtotbudget i.conditie50 woman educ polexperience  mathskill righttoleft if politician==1
outreg using control1log.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)


***Table S11. The effect of experience on the use of the representativeness heuristic in the various scenarios.
logit conjunction polexperience if politician==1
outreg using experiencelog.doc, replace se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logheadlines_comb c.polexperience##i.terrorcon if politician==1
outreg using experiencelog.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logearthquake_comb c.polexperience##i.aardbevingcon if politician==1
outreg using experiencelog.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg issueimportance c.polexperience##i.conditie50 if politician==1
outreg using experiencelog.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logtotbudget c.polexperience##i.conditie50 if politician==1
outreg using experiencelog.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)

***Table S12. The effect of expertise on the use of the representativeness heuristic in the nuisance scenario.
reg issueimportance i.openveiligheid##i.conditie50 if politician==1
outreg using expertise1.doc, replace se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logtotbudget i.openveiligheid##i.conditie50 if politician==1
outreg using expertise1.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)

***Table S13. The effect of education on the use of the representativeness heuristic in the various scenarios.
reg logheadlines_comb c.educ##i.terrorcon if politician==1
outreg using educ#.doc, replace se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logearthquake_comb c.educ##i.aardbevingcon if politician==1 
outreg using educ#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg issueimportance c.educ##i.conditie50 if politician==1 
outreg using educ#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
regress logtotbudget c.educ##i.conditie50 if politician==1
outreg using educ#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)


**Table S14. The effect of math skill on the use of the representativeness heuristic in the various scenarios.
reg logheadlines_comb c.mathskill##i.terrorcon if politician==1
outreg using math#.doc, replace se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logearthquake_comb c.mathskill##i.aardbevingcon if politician==1 
outreg using math#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg issueimportance c.mathskill##i.conditie50 if politician==1 
outreg using math#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
regress logtotbudget c.mathskill##i.conditie50 if politician==1
outreg using math#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)

**Table S15. The likelihood to use of the representativeness heuristic in other scenarios when shown to make the conjunction error in the Vera scenario.
reg logheadlines_comb i.conjunction##i.terrorcon if politician==1
outreg using linda#.doc, replace se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg logearthquake_comb i.conjunction##i.aardbevingcon if politician==1 
outreg using linda#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
reg issueimportance i.conjunction##i.conditie50 if politician==1 
outreg using linda#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)
regress logtotbudget i.conjunction##i.conditie50 if politician==1
outreg using linda#.doc, merge se starlevels(5,1,0.1) starloc(1)   sdec(2)


